package com.zy.edu.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.edu.bean.InputParam;
import com.zy.edu.bean.Log;
import com.zy.edu.bean.Region;
import com.zy.edu.bean.ResponseInfo;
import com.zy.edu.config.SystemParam;
import com.zy.edu.dao.LogDao;
import com.zy.edu.service.LogService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author HuangHaiShui
 * @since 2021-08-24
 */
@Service
public class LogServiceImpl extends ServiceImpl<LogDao, Log> implements LogService {

    @Override
    public Integer statsByJurisId(InputParam inputParam) {
        //获取当月第一天和最后一天
        Calendar cale = null;
        cale = Calendar.getInstance();
        // 获取当月第一天和最后一天
        SimpleDateFormat formatTemp = new SimpleDateFormat("yyyy-MM-dd");
        String firstday, lastday;
        // 获取当前月的第一天
        cale = Calendar.getInstance();
        cale.add(Calendar.MONTH, 0);
        cale.set(Calendar.DAY_OF_MONTH, 1);
        firstday = formatTemp.format(cale.getTime());
        // 获取当前月的最后一天
        cale = Calendar.getInstance();
        cale.add(Calendar.MONTH, 1);
        cale.set(Calendar.DAY_OF_MONTH, 0);
        lastday = formatTemp.format(cale.getTime());
//        System.out.println("firstday:"+firstday+" lastday:"+lastday);

        EntityWrapper<Log> entityWrapper = new EntityWrapper<>();
        entityWrapper.eq("juris_id", inputParam.getJurisId());
        entityWrapper.ge("create_time",firstday);
        entityWrapper.le("create_time",lastday);
        Integer count = this.baseMapper.selectCount(entityWrapper);
        return count;
    }
}
